<template>
  <view class="page-detail">
    <view class="page-detail-item">
      <text class="item-title">销售统计单编号：</text>
      <view class="title-info">{{detail.ticketCode}}
        <u-button type=" btnBase" @click="importPdf(detail.pdfPath)">下载</u-button>
      </view>
    </view>
    <view class="page-detail-item">
      <text class="item-title">企业名称：</text>
      <text>{{detail.companyName}}</text>
    </view>
    <view class="page-detail-item">
      <u-row justify="space-between" gutter="6">
        <u-col span="6">
          <view class="">
            <text class="item-title">企业类型：</text>
            <text>{{detail.companyType}}</text>
          </view>
        </u-col>
        <u-col span="6">
          <view class="">
            <text class="item-title">单位属性：</text>
            <text>{{detail.customer_attribute}}</text>
          </view>
        </u-col>
      </u-row>
    </view>
    <view class="page-detail-item">
      <u-row justify="space-between" gutter="6">
        <u-col span="6">
          <view class="">
            <text class="item-title">是否保供：</text>
            <text>{{detail.isPotect == '1' ? '否' : '是'}}</text>
          </view>
        </u-col>
        <u-col span="6">
          <view class="">
            <text class="item-title">随行人：</text>
            <text>{{detail.accompanyPerson}}</text>
          </view>
        </u-col>
      </u-row>
    </view>
    <view class="page-detail-item">
      <u-row justify="space-between" gutter="6">
        <u-col span="6">
          <view class="">
            <text class="item-title">司机姓名：</text>
            <text>{{detail.driverName}}</text>
          </view>
        </u-col>
        <u-col span="6">
          <view class="">
            <text class="item-title">电话：</text>
            <text>{{detail.phone}}</text>
          </view>
        </u-col>
      </u-row>
    </view>
    <view class="page-detail-item">
      <u-row justify="space-between" gutter="6">
        <u-col span="6">
          <view class="">
            <text class="item-title">车牌号：</text>
            <text>{{detail.carCode}}</text>
          </view>
        </u-col>
        <u-col span="6">
          <view class="">
            <text class="item-title">车型：</text>
            <text>{{detail.carTypeName}}</text>
          </view>
        </u-col>
      </u-row>
    </view>
    <view class="page-detail-item">
      <u-row justify="space-between" gutter="10">
        <u-col span="6">
          <view class="">
            <text class="item-title">煤种：</text>
            <text>{{detail.coalName}}</text>
          </view>
        </u-col>
        <u-col span="6">
          <view class="">
            <text class="item-title">净重：</text>
            <text>{{detail.netWeight}} 吨</text>
          </view>
        </u-col>
      </u-row>
    </view>
    <view class="page-detail-item">
      <u-row justify="space-between" gutter="10">
        <u-col span="6">
          <view class="">
            <text class="item-title">皮重：</text>
            <text>{{detail.tareWeight}} 吨</text>
          </view>
        </u-col>
        <u-col span="6">
          <view class="">
            <text class="item-title">毛重：</text>
            <text>{{detail.grossWeight}} 吨</text>
          </view>
        </u-col>
      </u-row>
    </view>
    <view class="page-detail-item">
      <u-row justify="space-between" gutter="10">
        <u-col span="6">
          <view class="">
            <text class="item-title">单价：</text>
            <text>{{detail.unitPrice}}</text>
          </view>
        </u-col>
        <u-col span="6">
          <view class="">
            <text class="item-title">总价：</text>
            <text>{{detail.totalPrice}}</text>
          </view>
        </u-col>
      </u-row>
    </view>
    <view class="page-detail-item">
      <text class="item-title">购买方：</text>
      <text>{{detail.purchaser}}</text>
    </view>
    <view class="page-detail-item">
      <text class="item-title">注册地址：</text>
      <text>{{detail.regAddress}}</text>
    </view>
    <view class="page-detail-item">
      <text class="item-title">卸货方：</text>
      <text>{{detail.unloader}}</text>
    </view>
    <view class="page-detail-item">
      <text class="item-title">卸货企业类型：</text>
      <text>{{detail.unloaderType}}</text>
    </view>
    <view class="page-detail-item">
      <text class="item-title">卸货地址：</text>
      <text>{{detail.unloadAddress}}</text>
    </view>
    <view class="page-detail-item">
      <text class="item-title">卸货打卡地址：</text>
      <text style="color: #0081FF;" @click="previewMap">{{detail.punchAddress}}</text>
    </view>

    <view class="page-detail-item">
      <text class="item-title">开具员：</text>
      <text>{{detail.makeInvoicePerson}}</text>
    </view>
    <view class="page-detail-item">
      <text class="item-title">开具时间：</text>
      <text>{{detail.makeInvoiceTime}}</text>
    </view>
    <!-- <view class="page-detail-item">
            <text class="item-title">溯源二维码：</text>
            <text style="color: #0081FF;" @click="preview">查看</text>
        </view> -->
  </view>
</template>

<script>
  import {
    getByTicketCode, exportPdfData
  } from "@/api/cockpit/cockpit";
  import config from "@/config";
  export default {
    props: {
      ticketCode: {
        type: String
      },
      pCode: {
        type: String
      }
    },
    data() {
      return {
        detail: {},
        baseUrl: config.baseUrl,
      }
    },
    onShow() {
      // this.getDetail();
      // this.getExportPdfData();
    },
    onLoad(option) {
      this.code = option.ticketCode;
      // this.code = '90232023031200012';
    },
    methods: {
      importPdf(name) {
        let urlInfo = this.baseUrl + "/system/oss/public/" + name;
        plus.runtime.openURL(urlInfo);
      },
      previewMap() {
        if (this.detail.szwz != '') {
          this.$tab.navigateTo(`/pages/home/mapdetail?szwz=${this.detail.szwz}`)
        } else {
          this.$modal.msg('位置不存在');
        }

      },
      async getDetail() {
        let res = await getByTicketCode({ ticketCode: this.code }) || {}
        this.detail = res.data
      },
      preview() {
        this.$tab.navigateTo(`/pages/common/qrcode/index?code=${this.detail.qrCodePath}`)
      }
    }
  }
</script>

<style lang="less" scoped>
  .title-info {
    display: flex;
  }

  .title-info>span {
    display: flex;
  }

  .btnBase {
    width: 112rpx !important;
    height: 41rpx !important;
    background: red;
    color: #ffffff;
  }

  .title-info .u-button {
    display: flex;
  }

  .page-detail {
    background-color: #ffffff;
    overflow: auto;
  }

  .page-detail-item {
    line-height: 60rpx;
  }
</style>